From 7459d430eb5a8cd94462b0a1ad068e89384294f9 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 19 Nov 2021 23:19:14 +0100 Subject: [PATCH] widget: Don't forget margins when adjusting This could lead to the wrong values being passed and computing invalid sizes which would then lead to very unhappy code. Test included. --- gtk/gtkwidget.c | 4 ++-- testsuite/reftests/meson.build | 2 ++ .../wrap-margin-align-critical.ref.ui | 20 ++++++++++++++++++ .../reftests/wrap-margin-align-critical.ui | 21 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 testsuite/reftests/wrap-margin-align-critical.ref.ui create mode 100644 testsuite/reftests/wrap-margin-align-critical.ui diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 788cfb6650..73dc6b20be 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3846,7 +3846,7 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, &allocation->x, &allocation->width); gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, - allocation->width, + allocation->width + priv->margin.left + priv->margin.right, &min_height, &natural_height, NULL, NULL); adjust_for_align (priv->valign, natural_height - priv->margin.top - priv->margin.bottom, @@ -3867,7 +3867,7 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, &allocation->y, &allocation->height); gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, - allocation->height, + allocation->height + priv->margin.top + priv->margin.bottom, &min_width, &natural_width, NULL, NULL); adjust_for_align (effective_align (priv->halign, _gtk_widget_get_direction (widget)), natural_width - priv->margin.left - priv->margin.right, diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index eb277d8bf7..01f813bee5 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -527,6 +527,8 @@ testdata = [ # it is not in xfail since it succeeds on some platforms #'window-show-contents-on-map.ref.ui', #'window-show-contents-on-map.ui', + 'wrap-margin-align-critical.ref.ui', + 'wrap-margin-align-critical.ui', ] # These need to be fixed but the issue hasn't been tracked down. diff --git a/testsuite/reftests/wrap-margin-align-critical.ref.ui b/testsuite/reftests/wrap-margin-align-critical.ref.ui new file mode 100644 index 0000000000..04d550c82d --- /dev/null +++ b/testsuite/reftests/wrap-margin-align-critical.ref.ui @@ -0,0 +1,20 @@ + + + + 300 + 300 + 0 + + + center + + + center + Hello World + True + + + + + + diff --git a/testsuite/reftests/wrap-margin-align-critical.ui b/testsuite/reftests/wrap-margin-align-critical.ui new file mode 100644 index 0000000000..b69c770f09 --- /dev/null +++ b/testsuite/reftests/wrap-margin-align-critical.ui @@ -0,0 +1,21 @@ + + + + 300 + 300 + 0 + + + center + 50 + 50 + + + Hello World + True + + + + + + -- 2.30.2